package ants.p2p.utils.indexer;

import java.io.*;

public class DirInfos implements Serializable, Comparable{
  String absolutePath = null;
  long lastModified;
  boolean indexed = false;

  public DirInfos(String absolutePath, long lastModified) {
    this.absolutePath = absolutePath;
    this.lastModified = lastModified;
  }

  public File getFile(){
    return new File(this.absolutePath);
  }

  public void setIndexed(){
    this.indexed = true;
  }

  /*public void resetIndexed(){
    this.indexed = false;
  }*/

  public boolean getIndexed(){
    return this.indexed;
  }

  public String getAbsolutePath(){
    return (new File(this.absolutePath)).getAbsolutePath();
  }

  public long getLastModified(){
    return this.lastModified;
  }

  public long setLastModified(long lastModified){
    return this.lastModified = lastModified;
  }

  public boolean equals(Object o){
    if(o instanceof DirInfos)
      return this.getFile().equals(((DirInfos)o).getFile());
    else if(o instanceof File)
      return (new File(this.absolutePath)).equals(o);
    else
      return this == o;
  }

  public int compareTo(Object o){
    return this.toString().compareTo(o.toString());
  }

  public String toString(){
    return this.absolutePath;
  }
}
